const { defineConfig } = require("@vue/cli-service")
const path = require("path")
function resolve(dir) {
  return path.join(__dirname, dir)
}
function setupSvg(config) {
  config.module.rule("svg").exclude.add(resolve("src/assets/svg")).end()
  config.module
    .rule("icons")
    .test(/\.svg$/)
    .include.add(resolve("src/assets/svg"))
    .end()
    .use("svg-sprite-loader")
    .loader("svg-sprite-loader")
    .options({
      symbolId: "icon-[name]"
    })
    .end()
}
// const BundleAnalyzerPlugin =
//   require("webpack-bundle-analyzer").BundleAnalyzerPlugin
const nodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = defineConfig({
  publicPath: "./",
  productionSourceMap: false,
  transpileDependencies: true,
  configureWebpack: {
    plugins: [new nodePolyfillPlugin()],
    resolve: {
      fallback: {
        fs: false,
        crypto: require.resolve("crypto-browserify"),
        stream: require.resolve("stream-browserify")
      }
    },
    devtool: "source-map"
  },
  devServer: {
    client: {
      overlay: false
    },
    proxy: {
      "/monster-im": {
        target: "http://192.168.3.84:3000",
        changeOrigin: true
        // pathRewrite: {
        //   "^/monster-im": ""
        // }
      }
    }
    // https: true
  },
  css: {},
  chainWebpack(config) {
    setupSvg(config)
  }
})
